package com.aixin.project.servlet;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.Template;
import org.apache.velocity.context.Context;

import com.aixin.project.data.User;
import com.aixin.project.handler.UserHandler;

public class UserValidateServlet extends BaseServlet{

	@Override
	protected Template execute(HttpServletRequest request, HttpServletResponse response, Context ctx) {
		String username = request.getParameter("username");
		response.setContentType("text/html;charset=UTF-8");
	      try {//
	    	  User u = UserHandler.find(username);
	    	  if(null == u)
			      response.getWriter().println("1");
	    	  else
	    		  response.getWriter().println("0");
		} catch (IOException e) {
			e.printStackTrace();
		}
	      return null;
	}

}
